package com.secsbrain.development.web.dto;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.secsbrain.cmdb.client.model.App;
import com.secsbrain.deploy.client.model.DeployParam;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.hibernate.validator.constraints.NotEmpty;

import javax.validation.constraints.NotNull;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;

@ApiModel(value = "部署应用信息")
public class AppDetailDTO implements Serializable{
	
	private static final long serialVersionUID = 4003075932577514349L;

	@ApiModelProperty(value = "应用ID")
	private Long id;

	@NotEmpty
	@ApiModelProperty(value = "应用名称")
	private String appName;

	@NotEmpty
	private String gitUrl;

	@NotEmpty
	@ApiModelProperty(value = "应用描述")
	private String appDesc;

	@NotNull
	@ApiModelProperty(value = "应用类型")
	private String appType;
	
	private String level;//系统等级

	private Boolean switchflow;
	
	private String sfEnv;

	@ApiModelProperty(value = "部署模型列表")
	private List<DeploymentInfo> deploymentList = new ArrayList<>();

	private boolean hasEnv;

	@Deprecated
	private DeployParam buildModelDto;
	
	private App app;//界面使用

	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
	private Date createdTime;
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
	private Date updatedTime;

	@ApiModelProperty(value = "OWNER")
	private String appOwnerName;

	@ApiModelProperty(value = "质量负责人")
	private String qualityName;

	private Long appOwner;

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getAppName() {
		return appName;
	}

	public void setAppName(String appName) {
		this.appName = appName;
	}

	public String getGitUrl() {
		return gitUrl;
	}

	public void setGitUrl(String gitUrl) {
		this.gitUrl = gitUrl;
	}

	public String getAppDesc() {
		return appDesc;
	}

	public void setAppDesc(String appDesc) {
		this.appDesc = appDesc;
	}

	public String getAppType() {
		return appType;
	}

	public void setAppType(String appType) {
		this.appType = appType;
	}

	public Boolean isSwitchflow() {
		return switchflow;
	}

	public void setSwitchflow(Boolean switchflow) {
		this.switchflow = switchflow;
	}

	public String getSfEnv() {
		return sfEnv;
	}

	public void setSfEnv(String sfEnv) {
		this.sfEnv = sfEnv;
	}

	public Date getCreatedTime() {
		return createdTime;
	}

	public void setCreatedTime(Date createdTime) {
		this.createdTime = createdTime;
	}

	public Date getUpdatedTime() {
		return updatedTime;
	}

	public void setUpdatedTime(Date updatedTime) {
		this.updatedTime = updatedTime;
	}

	public String getAppOwnerName() {
		return appOwnerName;
	}

	public void setAppOwnerName(String appOwnerName) {
		this.appOwnerName = appOwnerName;
	}

	public Long getAppOwner() {
		return appOwner;
	}

	public void setAppOwner(Long appOwner) {
		this.appOwner = appOwner;
	}

	public List<DeploymentInfo> getDeploymentList() {
		return deploymentList;
	}

	public void setDeploymentList(List<DeploymentInfo> deploymentList) {
		this.deploymentList = deploymentList;
	}

	@Deprecated
	public DeployParam getBuildModelDto() {
		return buildModelDto;
	}

	@Deprecated
	public void setBuildModelDto(DeployParam buildModelDto) {
		this.buildModelDto = buildModelDto;
	}

	public App getApp() {
		return app;
	}

	public void setApp(App app) {
		this.app = app;
	}
	
	public String getLevel() {
		return level;
	}

	public void setLevel(String level) {
		this.level = level;
	}

	public String getQualityName() {
		return qualityName;
	}

	public void setQualityName(String qualityName) {
		this.qualityName = qualityName;
	}

	public boolean isHasEnv() {
		return hasEnv;
	}

	public void setHasEnv(boolean hasEnv) {
		this.hasEnv = hasEnv;
	}

	@Override
	public boolean equals(Object o) {
		if (this == o)
			return true;
		if (o == null || getClass() != o.getClass())
			return false;

		AppDetailDTO that = (AppDetailDTO) o;

		return id.equals(that.id);
	}

	@Override
	public int hashCode() {
		return id.hashCode();
	}

	@ApiModel(value = "构建模型")
	public static class DeploymentInfo {
		private Long id;
		private Long serverId;
		private String serverHostName;

		@ApiModelProperty(value = "环境名称")
		private String env;

		@ApiModelProperty(value = "部署参数")
		private DeployParam deployParam;

		private boolean deploying;

		public Long getId() {
			return id;
		}

		public void setId(Long id) {
			this.id = id;
		}

		public Long getServerId() {
			return serverId;
		}

		public void setServerId(Long serverId) {
			this.serverId = serverId;
		}

		public String getServerHostName() {
			return serverHostName;
		}

		public void setServerHostName(String serverHostName) {
			this.serverHostName = serverHostName;
		}

		public String getEnv() {
			return env;
		}

		public void setEnv(String env) {
			this.env = env;
		}

		public boolean isDeploying() {
			return deploying;
		}

		public void setDeploying(boolean deploying) {
			this.deploying = deploying;
		}

		public DeployParam getDeployParam() {
			return deployParam;
		}

		public void setDeployParam(DeployParam deployParam) {
			this.deployParam = deployParam;
		}
	}
}
